﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script type="text/javascript" src="00.jquery-2.0.3.js" charset="gb2312" ></script>
</head>
<body>

    <input type="text" id="myInput" value="123"  class="class1 class2 "/>

    <div id="myDiv">
        <p>代理事件</p>
        <button   value="点我" style=" width:50px; height:20px"></button>
    </div>

    <script type="text/javascript">
        $(function () {
            //事件的绑定
            var $myInput = $("#myInput");
            $myInput.bind({
                "click": function () { alert(1) },
                "focus": function () { alert(2) },
                "keyup": function () { alert(3) },
                "kyeydown": function () { alert(4) },
                "click": function () { alert(5)}
            })
            function fn1() {
                    alert(6)
            }
            $myInput.bind("click", fn1);

            //事件的代理
            var $myDiv = $("#myDiv");
            $myDiv.bind("click", function () { alert(1) });
            $myDiv.delegate("button", "click", function () { alert(2) });


        });
    </script>
</body>
</html>
